package route

import (
	"github.com/gin-contrib/gzip"
	"github.com/gin-contrib/requestid"
	"github.com/gin-gonic/gin"
	"kpt-dtm/http/middleware"
)

func Root(opts ...func(engine *gin.Engine)) func(s *gin.Engine) {
	return func(s *gin.Engine) {
		for _, opt := range opts {
			opt(s)
		}

		// common middleware
		s.Use(
			middleware.CORS(),
			middleware.Pagination(),
			requestid.New(),
			gzip.Gzip(gzip.DefaultCompression),
		)
	}
}
